import React, { useState, useContext } from 'react';
/* 引入第二个全局的context */
import { myContext_two } from './ContextBox';
import ContextChil3 from './ContextChil3';

export default function TwoContext() {
  // 第二个 context 数据
  const my_contextTwo = useContext(myContext_two);

  const [, setUpdata] = useState();

  const changeContextVal = () => {
    // console.log( my_contextTwo );
    my_contextTwo.total += Date.now();
    setUpdata(Date.now());
  };

  return (
    <div>
      <p>context名称：{my_contextTwo?.spaceName}</p>
      <p>context数据：{my_contextTwo?.total}</p>
      <button onClick={changeContextVal}>修改 context2 中的值</button>

      <ContextChil3 />
    </div>
  );
}
